package com.aaa.mrcai.service.impl;

import com.aaa.mrcai.mapper.MoreGoodsMapper;
import com.aaa.mrcai.pojo.entity.Category;
import com.aaa.mrcai.pojo.entity.StoreGoods;
import com.aaa.mrcai.result.AjaxResult;
import com.aaa.mrcai.service.MoreGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * TODO
 *
 * @author 惠普
 * @date 2021/12/15  14:37
 */
@Service
public class MoreGoodsServiceImpl implements MoreGoodsService {

    @Autowired
    private MoreGoodsMapper moreGoodsMapper;
    @Override
    public AjaxResult listMoreGoods(int cid) {
        List<StoreGoods> storeGoods = moreGoodsMapper.listMoreGoods(cid);
        Category category = moreGoodsMapper.getCategory(cid);
        Map<String, Object> map = new HashMap<>();
        map.put("goods",storeGoods);
        map.put("category",category);
        if(map.size()>0){
            return AjaxResult.success(map);
        }else {
            return AjaxResult.defeated();
        }
    }
}
